ARG GO_VERSION
ARG UBUNTU_VERSION

FROM ubuntu:${UBUNTU_VERSION} AS base
WORKDIR /
RUN apt update && apt install -y ca-certificates && rm -rf /var/lib/apt/lists/*

FROM golang:${GO_VERSION} AS builder

ENV GOPATH /usr
ENV APP	   ${GOPATH}/src/github.com/fission/fission/environments/go

WORKDIR ${APP}

ADD server.go   ${APP}

RUN go mod init
RUN go mod tidy
RUN go build -a -o /server server.go

FROM base
COPY --from=builder /server /

ENTRYPOINT ["/server"]
EXPOSE 8888
